
******************************************************************************************
* highest education qualification by age 23
******************************************************************************************

replace HiQual_I20=HiQual_I23 if HiQual_I23>HiQual_I20 & HiQual_I23!=.
replace HiQual_I20=HiQual_I33 if HiQual_I33>HiQual_I20 & HiQual_I33!=.
drop HiQual_I23 HiQual_I33 

ta HiQual_I20, gen(HiQual_I20)
rename HiQual_I20* HiQual*_I20
drop HiQual_I20

forvalues v=1/6{
local u=`v'-1
rename HiQual`v'_I20 HiQual`u'_I20
}


ge QuGe1_I20=1-HiQual0_I20
ge QuGe2_I20=QuGe1_I20-HiQual1_I20
ge QuGe3_I20=QuGe2_I20-HiQual2_I20
ge QuGe4_I20=QuGe3_I20-HiQual3_I20
ge QuGe5_I20=QuGe4_I20-HiQual4_I20

******************************************************************************************
* Number of O levels and A levels
******************************************************************************************

drop  ALevels_I23 ALevels_I33 NALevels_I23 OLevels_I23 OLevels_I33 NOLevels_I23 ALevels_I23

rename *_I20 *_I23

* truncated qualification number
ge NOLevelsc_I23= NOLevels if  NOLevels>0
ge NALevelsc_I23= NALevels if  NALevels>0

local Q NOLevels NOLevelsc NALevels NALevelsc OLevels ALevels HiQual*
foreach q of local Q{
rename `q'_I23 `q'_E23
}



